﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.woodsoft.core;
using com.woodsoft.core.Files;
using EQ1.Objects;

namespace EQ1.Elements {
  public class StaticText:StaticScreenPiece, IUIElement<StaticText> {
    public StaticText ( UIDocument doc , string name ) : base( doc , name ) {
      this.NoWrap = false;
      this.AlignCenter = false;
      this.AlignRight = false;
    }
    public StaticText ( UIDocument doc ) : this( doc , "StaticText" ) {
    }

    #region IUIElement<StaticText> Members

    public void Validate ( StaticText val , string name ) {
      UIClass par = ( UIClass ) this.ParentNode;

      if( val.LocalName != name ) {
        StaticText el = new StaticText( ( UIDocument ) val.OwnerDocument , name );
        el.Copy( val );
        val = el;
      }

      if( par.GetElement( name ) != null )
        par.RemoveElement( name );

      par.AppendChild( val );
    }
    public void Copy ( StaticText val ) {
      base.Copy( val );

      this.NoWrap = val.NoWrap;
      this.AlignCenter = val.AlignCenter;
      this.AlignRight = val.AlignRight;

    }

    #endregion

    public bool NoWrap {
      get {
        return bool.Parse( this.GetElement( "NoWrap" ).InnerText );
      }
      set {
        this.Validate( "NoWrap" , value.ToString() );
      }
    }
    public bool AlignCenter {
      get {
        return bool.Parse( this.GetElement( "AlignCenter" ).InnerText );
      }
      set {
        this.Validate( "AlignCenter" , value.ToString() );
      }
    }
    public bool AlignRight {
      get {
        return bool.Parse( this.GetElement( "AlignRight" ).InnerText );
      }
      set {
        this.Validate( "AlignRight" , value.ToString() );
      }
    }
  }
}
